<!-- 城市配置 -->
<template>
  <div>{{ cityInfo || '' }}</div>
  <div class="table">
    <dt-grid ref="tableRef" :onFetch="onFetch" page></dt-grid>
  </div>
</template>

<script setup>
  import { ref, onMounted } from 'vue'
  import apiMgr from '../biz/index.js'
  import { listOpt } from '../opt/columns.js'
  import { useRouter } from 'vue-router'
  const router = useRouter()

  const [tableRef] = [ref()]
  let cityInfo = ref(null)
  onMounted(() => {
    tableRef.value.init(new listOpt(fn))
    tableRef.value.fetch()
    citySettingTip()
  })

  const fn = {
    //查看
    toView: (data) => {
      router.push({
        path: '/tenant/config/cityConfig/detail',
        query: {
          cityCode: data.cityCode
        }
      })
    }
  }
  function citySettingTip() {
    apiMgr.citySettingTip().then((res) => {
      cityInfo.value = res
    })
  }
  function onFetch(obj) {
    let params = {
      ...obj,
      level: 3
    }
    return apiMgr.citySetting(params).then((res) => {
      return res
    })
  }
</script>

<style scoped lang="scss"></style>
